Repository navigation
feat: allow disabling sign up with email and password - #9043
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
Self-hosters who run a single organization behind SSO want to stop new users from creating email and password accounts, while organization admins (who cannot be SSO users today) keep signing in with their email and password. Add the AUTH_EMAIL_PASSWORD_REGISTRATION environment variable to the server and the app. It defaults to 1, so nothing changes unless it is set to 0: - server: POST /auth-api/signup answers SIGN_UP_NOT_ALLOWED right after the rate limit check, before the email address is looked up, so a disabled sign up also no longer tells whether an account exists. Sign in, password reset and the third-party/OIDC flows are untouched. - app: the variable is exposed to the frontend and validated on start. The sign-up page drops the email and password form and only lists the enabled providers. If no provider is enabled either, nobody can sign up, so /auth/sign-up redirects to the sign-in page (keeping redirectToPath) and the sign-in page hides its "Sign up" link. The community docker compose file passes the variable through to both services, and the server and app READMEs document it. Tests cover the server route with the flag on and off, the redirect and the hidden link when no sign up method is left, the provider-only sign-up page, and that existing users still sign in. Closes graphql-hive#8039
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Closes #8039. Self-hosters running a single organization with SSO want to stop new users from creating email and password accounts, while organization admins (who can't be SSO users today) keep signing in with their email and password.
Description
Adds the
AUTH_EMAIL_PASSWORD_REGISTRATIONenvironment variable proposed in the issue. It defaults to1, so nothing changes unless it is set to0.server
POST /auth-api/signupanswersSIGN_UP_NOT_ALLOWEDwhen the variable is0. The check runs right after the rate limit, before the email address is looked up, so a disabled sign up also doesn't reveal whether an account exists.app
/auth/sign-upredirects to the sign-in page (keepingredirectToPath) and the sign-in page hides its "Sign up" link.Like
AUTH_REQUIRE_EMAIL_VERIFICATION, the variable has to be set on both theserverand theappservice. The community compose file passes it through to both (${AUTH_EMAIL_PASSWORD_REGISTRATION:-1}), and the server and app READMEs document it. Changeset included.Tests:
packages/services/server/__tests__/supertokens-at-home-sign-up.spec.ts: the sign-up route with the variable on and off, throughfastify.inject. The integration test stack runs one server with a fixed environment, so I covered the route with a unit test instead.packages/web/app/src/pages/auth-email-password.spec.tsandauth-sign-up.spec.ts: the redirect and hidden link when no sign up method is left, the SSO-only sign-up page, and existing users still signing in.Verified locally: the new and existing auth specs (the new cases fail without the change),
tsc --noEmitfor@hive/serverand@hive/app, oxlint and prettier.Checklist